<template>
    <div class="destail2">
        <div class="destail22">
            <ul class="ul1">
                <li class="clearfix">
                    <span class="spa">单位名称</span>
                    <em>{{listArr.ProjectName}} </em>
                </li>
                <li class="clearfix" >
                    <span class="spa">分部工程</span>
                    <em>{{listArr.SubSectionProject}}</em>
                </li>
                <li class="clearfix" >
                    <span class="spa">分项工程</span>
                    <em>{{listArr.SubProject}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">危险源</span>
                    <em>{{listArr.Hazards}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">危险因素</span>
                    <em>{{listArr.RiskFactors}}</em>
                </li>
                <li class="clearfix" >
                    <span class="spa">可能导致的事故类别</span>
                    <em>{{listArr.AccidentType}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">危险后果分类</span>
                    <em>{{listArr.Consequence}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">事故发生的可能性L</span>
                    <em>{{listArr.L}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">暴露的危险环境频繁程度E</span>
                    <em>{{listArr.E}} </em>
                </li>
                <li class="clearfix" >
                    <span class="spa">发生事故产生的后果C</span>
                    <em>{{listArr.C}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">D=L*E*C</span>
                    <em>{{listArr.D}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">风险等级</span>
                    <em>{{listArr.SourceLevel}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">是否为重大风险</span>
                    <em>{{listArr.IsBigSource}}</em>
                </li>
                <li class="clearfix" >
                    <span class="spa">管控措施</span>
                    <em>{{listArr.ControlMeasure}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">管控级别</span>
                    <em>{{listArr.ControlLevel}}</em>
                </li>
                <li class="clearfix">
                    <span class="spa">管控部门</span>
                    <em>{{listArr.ControlDepartment}}</em>
                </li>
            </ul>
            <div class="destail22Box" v-if="!leader">
                <h2>监控记录</h2>
                <ul class="destail" v-for="(item,index) in listArr2" :key="index" v-show="nodata">
                    <li @click="desGo(item)"><p>{{item.MoniToringStartTime}}</p> <x-icon type="ios-arrow-right" size="" class="icon-white"></x-icon></li>
                </ul>
                <!-- <ul class="destail"  v-show="!nodata">
                    <li><p>暂无数据...</p> </li>
                </ul> -->
                <noData v-if="listArr2 == 0"></noData>
            </div>
            <div class="destail22Box" v-if="leader">
                <h2>监控记录 <em @click="$router.push('/desMonitoring2')">监控历史记录</em></h2>
                <div class="queryDiv_top">
                    <ul class="ul11">
                        <li class="li clearfix">
                            <span class="spa">监控内容 <i>*</i></span>
                            <em @click="$router.push('./mont1')" v-if="!name1">默认本单位</em>
                            <em  @click="$router.push({path:'./mont1'})" v-else>{{name1}} </em>
                        </li>
                        <li class="li clearfix">
                            <span class="spa">监控地点 <i>*</i></span>
                            <em @click="$router.push('./mont2')" v-if="!name2">默认本单位</em>
                            <em  @click="$router.push({path:'./mont2'})" v-else>{{name2}} </em>
                        </li>
                        <li class="li clearfix">
                            <span class="spa">监控开始时间 <i>*</i></span>
                            <datetime v-model="star"  @on-change="change1"></datetime>
                        </li>
                        <li class="li clearfix">
                            <span class="spa">监控结束时间 <i>*</i></span>
                            <datetime v-model="end"  @on-change="change2"></datetime>
                        </li>
                        <li class="li clearfix">
                            <span class="spa">是否已交底</span>
                            <em>
                                <div>
                                    <input type="radio" value="0" @change="change3" v-model="radio1">否
                                </div>
                                <div>
                                    <input type="radio" value="1" @change="change3" v-model="radio1">是
                                </div>
                            </em>
                        </li>
                        <li class="li clearfix">
                            <span class="spa">监控人员 <i>*</i></span>
                            <em @click="$router.push('./mont4')" v-if="!name3">默认本单位</em>
                            <em  @click="$router.push({path:'./mont4',query:{radios:name3,type:1}})" v-else>{{name3}} </em>
                        </li>
                        <li class="li clearfix">
                            <span class="spa">监控责任人员 <i>*</i></span>
                            <em @click="$router.push('./mont4')" v-if="!name4">默认本单位</em>
                            <em  @click="$router.push({path:'./mont4',query:{radios:name4,type:2}})" v-else>{{name4}} </em>
                        </li>
                        <li class="clearfix" style="border-bottom:1px solid #eee">
                            <ul>
                                <li class="spa2" >监控过程记录 <i>*</i></li>
                                <li class="spa3" @click="$router.push('./mont3')"  v-if="!name5">请输入</li>
                                <li class="spa3" @click="$router.push({path:'./mont3',query:{radios:name5}})" >{{name5}} </li>
                            </ul>
                        </li>
                        <li class="li clearfix">
                            <span class="spa">危险源是否受控</span>
                            <em>
                                <div>
                                    <input type="radio" value="0" v-model="radio2" @change="change4">不受控
                                </div>
                                <div>
                                    <input type="radio" value="1" v-model="radio2" @change="change4">受控
                                </div>
                            </em>
                        </li>
                        <li class="clearfix" style="border-bottom:1px solid #eee">
                            <h1 class="h1">监控图片 <i>*</i></h1>
                            <div class="upload-wrap">
                                        <upload @setFormData="setFormData"
                                                :uploadImgss="hiddenmeta.uploadImgs"
                                                :images="hiddenmeta.images"
                                                :newBlobList="hiddenmeta.newBlobList"
                                                >
                                        </upload>
                                    </div>
                        </li>
                    </ul>
                    <div class="queryBtn" @click="btn" >提交</div>
                </div>
            </div>
        </div>
        <myMenu @clickBack="back" backPath='/riskMonitoring'></myMenu>
    </div>
</template>
<script>
import upload from '@/commonComponents/upload/index'
import { Actionsheet, Cell, Group, CellBox } from 'vux'
import myMenu from '@/commonComponents/menu'
export default {
  components: {
    Actionsheet,
    Group,
    Cell,
    CellBox,
    myMenu,
    upload
  },
  data () {
      return {
        button: false,
        nodata: true,
        leader: true,
        star: '请选择',
        end: '请选择',
        listArr: [],
        uploadImgs: [],
        images: [],
        newBlobList: [],
        hiddenmeta: {
            uploadImgs: [],
            images: [],
            newBlobList: []
        },
        parmas: {
            allowPaging: 'false',
            business: 'SubmitRiskDynamicManagement',
            data: {
                Id: '',
                MoniToringContent: '',
                MoniToringSite: '',
                MoniToringStartTime: '',
                MoniToringEndTime: '',
                MoniToringPerSonnel: '',
                GoodsDutyName: '',
                DisClose: '0',
                MoniToringRecord: '',
                IsConTrolled: '0'
            },
            pageIndex: 0,
            pageSize: 20000,
            tokenId: '',
            userId: ''
        },
        name1: '',
        name2: '',
        name3: '',
        name4: '',
        name5: '',
        radio1: '',
        radio2: '',
        formData: {},
        usermode: '',
        parmas2: {
            allowPaging: 'true',
            business: 'GetRiskDynamicRecord',
            data: {
                ID: ''
            },
            pageIndex: 0,
            pageSize: 20000,
            tokenId: '',
            userId: ''
        },
        listArr2: []
    }
  },
  created () {
      this.listArr = JSON.parse(window.sessionStorage.getItem('arr'))
      this.parmas.data.Id = this.listArr.ID
      this.parmas2.data.ID = this.listArr.ID
          // 开始时间
      if (window.sessionStorage.getItem('star')) {
          this.parmas.data.MoniToringStartTime = window.sessionStorage.getItem('star')
          this.star = window.sessionStorage.getItem('star')
      } else {
          this.parmas.data.MoniToringStartTime = ''
          this.star = '请输入'
      }
      // 结束时间
      if (window.sessionStorage.getItem('end')) {
          this.parmas.data.MoniToringEndTime = window.sessionStorage.getItem('end')
          this.end = window.sessionStorage.getItem('end')
      } else {
          this.parmas.data.MoniToringEndTime = ''
          this.end = '请输入'
      }
      var token = JSON.parse(window.localStorage.getItem('userInfo'))
      this.parmas.userId = token.userid
      this.parmas2.userId = token.userid
      var usermode = token.usermode
      var reg = RegExp(/项目安全员/)
      if (reg.test(usermode)) {
          this.leader = true
      }
      if (usermode.indexOf('项目安全员') != -1 || usermode.indexOf('项目安全总监') != -1) {
          this.button = true
      }
  },
  mounted () {
      this.dataArr()
    //   监控内容
      if (window.sessionStorage.getItem('MoniToringContent')) {
          this.parmas.data.MoniToringContent = window.sessionStorage.getItem('MoniToringContent')
          this.name1 = window.sessionStorage.getItem('MoniToringContent')
      } else {
          this.parmas.data.MoniToringContent = ''
          this.name1 = '请输入'
      }
    //   监控地点
      if (window.sessionStorage.getItem('MoniToringSite')) {
          this.parmas.data.MoniToringSite = window.sessionStorage.getItem('MoniToringSite')
          this.name2 = window.sessionStorage.getItem('MoniToringSite')
      } else {
          this.parmas.data.MoniToringSite = ''
          this.name2 = '请输入'
      }
    //   是否交底
      if (window.sessionStorage.getItem('radio1')) {
          this.parmas.data.DisClose = window.sessionStorage.getItem('radio1')
          this.radio1 = window.sessionStorage.getItem('radio1')
      } else {
          this.parmas.data.DisClose = '0'
          this.radio1 = '0'
      }
    //   监控过程记录
      if (window.sessionStorage.getItem('MoniToringRecord')) {
          this.parmas.data.MoniToringRecord = window.sessionStorage.getItem('MoniToringRecord')
          this.name5 = window.sessionStorage.getItem('MoniToringRecord')
      } else {
          this.parmas.data.MoniToringRecord = ''
          this.name5 = '请输入'
      }
      //   监控人员
      if (window.sessionStorage.getItem('name3')) {
          this.parmas.data.MoniToringPerSonnel = window.sessionStorage.getItem('name3')
          this.name3 = window.sessionStorage.getItem('name3')
      } else {
          this.parmas.data.MoniToringPerSonnel = ''
          this.name3 = '请选择'
      }
      //   责任人员
      if (window.sessionStorage.getItem('name4')) {
          this.parmas.data.GoodsDutyName = window.sessionStorage.getItem('name4')
          this.name4 = window.sessionStorage.getItem('name4')
      } else {
          this.parmas.data.GoodsDutyName = ''
          this.name4 = '请选择'
      }
    //   危险源是否受控
      if (window.sessionStorage.getItem('radio2')) {
          this.parmas.data.IsConTrolled = window.sessionStorage.getItem('radio2')
          this.radio2 = window.sessionStorage.getItem('radio2')
      } else {
          this.parmas.data.IsConTrolled = '0'
          this.radio2 = '0'
      }
  },
  methods: {
    back () {
        this.parmas.data.Id = ''
        this.parmas.data.MoniToringContent = '',
        this.parmas.data.MoniToringSite = '',
        this.parmas.data.MoniToringStartTime = '',
        this.parmas.data.MoniToringEndTime = '',
        this.parmas.data.MoniToringPerSonnel = '',
        this.parmas.data.GoodsDutyName = '',
        this.parmas.data.MoniToringRecord = '',
        window.sessionStorage.removeItem('arr'),
        window.sessionStorage.removeItem('radio1'),
        window.sessionStorage.removeItem('MoniToringSite'),
        window.sessionStorage.removeItem('name4'),
        window.sessionStorage.removeItem('MoniToringRecord'),
        window.sessionStorage.removeItem('id4'),
        window.sessionStorage.removeItem('id3'),
        window.sessionStorage.removeItem('end'),
        window.sessionStorage.removeItem('MoniToringContent'),
        window.sessionStorage.removeItem('name3'),
        window.sessionStorage.removeItem('star')
    },
    change1 (value) {
      if (value) {
            this.parmas.data.MoniToringStartTime = value
            this.star = value
            window.sessionStorage.setItem('star', value)
      }
    },
    change2 (value) {
      this.parmas.data.MoniToringEndTime = value
      this.end = value
      window.sessionStorage.setItem('end', value)
    },
    change3 (value) {
        window.sessionStorage.setItem('radio1', this.radio1)
        this.parmas.data.DisClose = this.radio1
    },
    change4 (value) {
        window.sessionStorage.setItem('radio2', this.radio2)
        this.parmas.data.IsConTrolled = this.radio2
    },
    setFormData (formData, uploadLength, uploadImgs, images, newBlobList) {
    // this.uploadImgFormData = formData
        console.log(formData, 13)
        this.formData = formData
    },
    // 提交
    btn () {
        if (this.parmas.data.MoniToringContent &&
            this.parmas.data.MoniToringSite &&
            this.parmas.data.MoniToringStartTime &&
            this.parmas.data.MoniToringEndTime &&
            this.parmas.data.MoniToringPerSonnel &&
            this.parmas.data.GoodsDutyName &&
            this.parmas.data.MoniToringRecord &&
            this.formData) {
            this.$vux.loading.show({
                text: '加载中...'
            })
            this.$axiosAjax.getConfigJson(this.parmas, this.formData).then((res) => {
                if (res.status == 200) {
                    this.$vux.loading.hide({
                        text: '加载中...'
                    })
                    this.$router.push({path: './riskMonitoring'})
                    this.parmas.data.Id = ''
                    this.parmas.data.MoniToringContent = '',
                    this.parmas.data.MoniToringSite = '',
                    this.parmas.data.MoniToringStartTime = '',
                    this.parmas.data.MoniToringEndTime = '',
                    this.parmas.data.MoniToringPerSonnel = '',
                    this.parmas.data.GoodsDutyName = '',
                    this.parmas.data.MoniToringRecord = '',
                    window.sessionStorage.removeItem('arr'),
                    window.sessionStorage.removeItem('radio1'),
                    window.sessionStorage.removeItem('MoniToringSite'),
                    window.sessionStorage.removeItem('name4'),
                    window.sessionStorage.removeItem('MoniToringRecord'),
                    window.sessionStorage.removeItem('id4'),
                    window.sessionStorage.removeItem('id3'),
                    window.sessionStorage.removeItem('end'),
                    window.sessionStorage.removeItem('MoniToringContent'),
                    window.sessionStorage.removeItem('name3'),
                    window.sessionStorage.removeItem('star')
                }
            })
        } else if (!this.parmas.data.MoniToringContent) {
            this.$vux.toast.text('监控内容必填')
        } else if (!this.parmas.data.MoniToringSite) {
            this.$vux.toast.text('检查组长必填')
        } else if (!this.parmas.data.MoniToringStartTime) {
            this.$vux.toast.text('开始时间必填')
        } else if (!this.parmas.data.MoniToringEndTime) {
            this.$vux.toast.text('结束时间必填')
        } else if (!this.parmas.data.MoniToringPerSonnel) {
            this.$vux.toast.text('监控人员必填')
        } else if (!this.parmas.data.GoodsDutyName) {
            this.$vux.toast.text('监控负责人必填')
        } else if (!this.parmas.data.MoniToringRecord) {
            this.$vux.toast.text('监控过程必填')
        } else if (!this.formData) {
            this.$vux.toast.text('请上传图片')
        }
    },
    dataArr () {
      this.$axiosAjax.getConfigJson(this.parmas2).then((res) => {
        if (res.status == 200) {
            this.listArr2 = res.data.data
            if (res.data.data != null && res.data.data.length > 0) {
                this.nodata = true
            } else {
                this.nodata = false
            }
        }
      })
    },
    desGo (item) {
        window.sessionStorage.setItem('arr2', JSON.stringify(item))
        this.$router.push('/infoDestail')
    }
  }
}
</script>
<style lang="less">
.destail2{
    width: 100%;
    height: 100%;
    .destail22{
        height: 100%;
        width: 100%;
        background-color: #ebeef2;
        padding-top: 10px;
        .ul1{
            width: 100%;
            padding: 0 10px;
            background-color: #fff;
            margin-bottom: 10px;
            li,li .ul_in{
                padding: 10px 0;
                border-bottom:1px solid #eee;
                width: 100%;
                height: 50px;
                line-height: 30px;
                position: relative;
                .vux-x-icon{
                    fill: #999;
                    float: right;
                    position: absolute;
                    top: 12px;
                    right: -10px;
                }
                .spa{
                    // float: left;
                    width: 136px;
                    font-size: 14px;
                    color: #333;
                }
                .spaTitle{
                    float: left;
                    height: 30px;
                    line-height: 30px;
                    font-size: 16px;
                    width: 196px;
                    color: #2269ff;
                }
                em{
                    float: right;
                    width: 180px;
                    height: 30px;
                    font-size: 14px;
                    line-height: 30px;
                    text-align: right;
                    margin-right: 10px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    color: #999;
                    .sp{
                        color: red!important;
                    }
                }
                .vux-cell-value{
                    float: right;
                    margin-right: 20px;

                }
            }
        }
        .destail22Box{
            h2{
                color: #2269ff;
                text-align: left;
                padding: 0 10px;
                height: 40px;
                line-height: 40px;
                box-sizing: border-box;
                background-color: #eee;
                em{
                    width: 80px;
                    height: 20px;
                    line-height: 20px;
                    text-align: center;
                    border-radius: 15px;
                    border: 1px solid #2269ff;
                    float: right;
                    font-size: 12px;
                    margin-top: 10px;
                }
            }
            .destail{
                width: 100%;
                background-color: #fff;
                li{
                    width: 100%;
                    height: 40px;
                    line-height: 40px;
                    padding-left: 20px;
                    box-sizing: border-box;
                p{
                        width: 300px;
                        float: left;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                }
                    .vux-x-icon{
                        fill:#000;
                        float: right;
                        width: 20px;
                        height: 20px;
                        margin: 10px 10px 0 0;
                    }
                }
            }
            .queryDiv_top{
                width: 100%;
                padding-bottom: 1px;
                background-color: #fff;
                .ul11{
                    padding: 0 10px;
                    .li{
                        padding: 10px 0;
                        border-bottom:1px solid #eee;
                        width: 100%;
                        height: 50px;
                        line-height: 30px;
                        position: relative;
                        font-size: 16px;
                        display: flex;
                        .vux-x-icon{
                            fill: #999;
                            float: right;
                            position: absolute;
                            width: 20px;
                            height: 20px;
                            top: 15px;
                            right: -10px;
                        }
                        .spa{
                            float: left;
                            height: 30px;
                            line-height: 30px;
                            width: 140px;
                            font-size: 14px!important;
                            color: #333;
                            i{
                                color: #fe0100;
                            }
                        }
                        .h4{
                            width: 375px;
                        }
                        em{
                            float: right;
                            color: #999;
                            width: 200px;
                            height: 30px;
                            font-size: 12px;
                            line-height: 30px;
                            text-align: right;
                            margin-right: 10px;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            white-space: nowrap;
                            div{
                                float: right;
                                margin-left: 20px;
                                width: 64px;
                                position: relative;
                                text-align: right;
                                color: #999;
                                input{
                                    width: 16px;
                                    height: 16px;
                                    position: absolute;
                                    top:6px;
                                    left: 10px;
                                    text-align: center;
                                }
                            }
                        }
                        h5{
                            width: 375px;
                            float: left;
                        }
                        .weui-cell{
                            padding: 0;
                            height: 28px;
                            z-index: 999999;
                            width: 259px;
                            height: 28px;
                        }
                        .vux-cell-value{
                            float: right;
                            width: 244px;
                            height: 28px;
                            font-size: 12px;
                            text-align: right;
                            color: #999;
                            margin-right: 16px;
                        }
                        .weui-cell_access .weui-cell__ft:after{
                            top: 46%;
                            width: 8px;
                            height: 8px;
                            content:0;
                        }
                        .vux-datetime .weui-cell .weui-cell_access {
                            width: 259px;
                            height: 28px;
                        }
                    }
                    .spa2{
                        float: left;
                        min-height: 30px;
                        line-height: 30px;
                        width:100%;
                        font-size: 14px!important;
                        color: #333;
                        i{
                            color: #fe0100;
                        }
                    }
                    .spa3{
                        min-height: 30px;
                        line-height: 24px;
                        width:100%;
                        font-size: 14px!important;
                        color: #333;
                    }
                    .h1{
                        min-height: 30px;
                        line-height: 30px;
                        width:100%;
                        font-size: 14px!important;
                        i{
                            color: #fe0100;
                        }
                    }
                }
                .queryBtn{
                    height: 30px;
                    line-height: 30px;
                    margin: 25px auto;
                    text-align: center;
                    width: 300px;
                    border-radius: 25px;
                    background-color: #2269ff;
                    letter-spacing: 4px;
                    color: #fff;
                }
            }
        }

    }
    .weui-cell:before{
        border-top:0!important
    }
    .weui-cell{
        padding:10px;
        border-bottom:0!important;
    }
    .vux-label{
        font-size: 16px;
    }
    .weui-cells{
        margin-top: 0;
    }
    .weui-cell__ft{
        em{
            font-size: 14px;
        }
    }
    .affirm-wrap {
        position: fixed;
        z-index: 5;
        bottom: 0;
        left: 0;
        right: 0;
        background: #ebeef2;
    }
    .iconfont{
        margin-left: 20px;
    }
    .item-wrap {
        background: #fff;
        position: relative;
        z-index: 2;
        margin-top: 5px;
    }
    .weui-cell_access .weui-cell__ft:after{
        display: none;
    }
    .noDestail{
        background-color: #fff;
        padding: 0 10px;
        height: 50px;
        line-height: 50px;
    }
}
</style>
